namespace GroupSix.Domain.Entity.App;

/// <summary>
/// 菜单实体
/// </summary>
public class GsMenu : EntityBase
{
    /// <summary>
    /// 菜单名称
    /// </summary>
    public string Menuname { get; set; } = null!;

    /// <summary>
    /// 菜单路径
    /// </summary>
    public string? MenuPath { get; set; }

    /// <summary>
    /// 菜单图标
    /// </summary>
    public string? MenuIcon { get; set; }

    /// <summary>
    /// 父菜单Id
    /// </summary>
    public Guid? ParentId { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    public int Order { get; set; }

    /// <summary>
    /// 权限标识
    /// </summary>
    public string? PermissionKey { get; set; }

    /// <summary>
    /// 子菜单集合
    /// </summary>
    public ICollection<GsMenu> Children { get; set; } = new List<GsMenu>();

    public ICollection<GsRoleMenu> GsRoleMenus { get; set; } = new List<GsRoleMenu>();

    public GsMenu() { }

    public GsMenu(string menuname, string? menuPath, string? menuIcon, Guid? parentId, int order, string? permissionKey)
    {
        Menuname = menuname;
        MenuPath = menuPath;
        MenuIcon = menuIcon;
        ParentId = parentId;
        Order = order;
        PermissionKey = permissionKey;
    }

    /// <summary>
    /// 更新菜单信息
    /// </summary>
    /// <param name="menuname">菜单名称</param>
    /// <param name="menuPath">菜单路径</param>
    /// <param name="menuIcon">菜单图标</param>
    /// <param name="parentId">父菜单ID</param>
    /// <param name="order">排序</param>
    /// <param name="permissionKey">权限标识</param>
    public void UpdateInfo(string menuname, string? menuPath, string? menuIcon, Guid? parentId, int order, string? permissionKey)
    {
        Menuname = menuname;
        MenuPath = menuPath;
        MenuIcon = menuIcon;
        ParentId = parentId;
        Order = order;
        PermissionKey = permissionKey;
        UpdatedAt = DateTime.UtcNow;
    }
}